// pages/login/login.js
let {
    wxApiPromisify
} = require('../../utils/util.js')
let {
    fetchWxLogin,fetchGetOpenid
} = require('../../api/user.js')
let wxProLogin = wxApiPromisify(wx.login)
Page({

    /**
     * 页面的初始数据
     */
    data: {

    },
    async login() {
        let { code } = await wxProLogin()
        let { token } = await fetchWxLogin()
        let {openid} = await fetchGetOpenid(code)
        console.log(openid);
        wx.setStorageSync('token', token);
        console.log(code);
        wx.setStorageSync('openid', openid);
        wx.showToast({
            title: '登录成功',
        })
        wx.switchTab({
            url: '/pages/movie/movie',
        })

    }

})